package edu.sctu.xialei.june.day20150610one;

import edu.sctu.xialei.june.day20150610one.modle.*;

import edu.sctu.xialei.june.day20150610one.util.*;

/**
 * Created by Administrator on 6/10/2015.
 */

//乘地铁流程
public class TakeTheSubway {
    public static void main(String[] args) {

//        实例化乘客和地铁站
        Passenger passenger = new SettingPassengerData().setPassenger();
        TrainStation trainStation = new SettingTrainStationData().setTrainStationData();


//        是否买票
        if (passenger.subwayCard == null){
            passenger.subwayCard = trainStation.ticketMachine.salesCard(passenger.startTrainStop,passenger.endTrainStop);
        }

//        安检
        trainStation.safetyInspector.inspection(passenger,trainStation.dangerousParcel,trainStation.dangerousWater);

//        刷卡进站
        passenger.subwayCard = trainStation.pos.creditCard(passenger.subwayCard,passenger);
        if (passenger.subwayCard.balance < trainStation.pos.minMoneyOfVip){
            trainStation.rechargingMachine.recharge(passenger.subwayCard,100);
        }
        System.out.println("*** 进站 ***");


//        刷卡出站
        passenger.subwayCard = trainStation.pos.creditCard(passenger.subwayCard,passenger);
        System.out.println("*** 出站 ***");
    }
}
